import * as api from '../../api/home'
import * as Type from '../action-type'
import * as Shop from '../../api/shopCar'
// import request from '../../utils/request'
const Home = {
    getHomeData() {
        return async (dispatch) => {
            let payload = await api.getNavList().then(res => {
                return res
            })
            dispatch({
                type: Type.Home,
                payload
            })
        }
    },
    Sx(index) {
        return ({
            type: Type.SX,
            payload: index
        })
    },
    Search(val) {
        return ({
            type: Type.Search,
            payload: val
        })
    },
    Jg(data) {
        console.log(data);
        return ({
            type: Type.JgSort,
            payload: data
        })
    },
    Xl(data) {
        return ({
            type: Type.XlSort,
            payload: data
        })
    },
    //添加购物车
    AddShopCar(res) {
        console.log(res);
        return async (dispatch) => {
            await Shop.addShopCar(res).then(res => {
                console.log(res.data);
            })
            dispatch({
                type: ''
            })
        }

    }
}
export default Home